﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Linq.Expressions;

using Sita.Data.Core;
using Sita.Data.Core.Specification;

namespace Sita.Data.Repositories
{
    public interface IGenericRepository<T> where T : class, new()
    {
        IContext StoreContext { get; }

        IEnumerable<T> GetAll();
        IEnumerable<T> GetBySpec(ISpecification<T> spec);
        IEnumerable<T> GetBySpec<S>(ISpecification<T> spec, Expression<Func<T, S>> orderByExpression, bool ascending);
        IEnumerable<T> GetAllPaginated<S>(int pageIndex, int pageSize, Expression<Func<T, S>> orderByExpression, bool ascending, out int totalRows);
        IEnumerable<T> GetAllPaginated<S>(int pageIndex, int pageSize, ISpecification<T> spec, Expression<Func<T, S>> orderByExpression, bool ascending, out int totalRows);
        IEnumerable<T> GetAllPaginated(int pageIndex, int pageSize, ISpecification<T> spec, string orderColumn, bool ascending, out int totalRows);
        IEnumerable<T> GetAllPaginated(int pageIndex, int pageSize, string orderColumn, bool ascending, out int totalRows);

        IEnumerable<T> GetAllPaginatedWithInclude(int pageIndex, int pageSize, string orderColumn, bool ascending, string include, out int totalRows);
        IEnumerable<T> GetAllPaginatedWithInclude(int pageIndex, int pageSize, ISpecification<T> spec, string orderColumn, bool ascending, string include, out int totalRows);
        IEnumerable<T> GetAllPaginatedWithInclude<S>(int pageIndex, int pageSize, Expression<Func<T, S>> orderByExpression, bool ascending, string include, out int totalRows);
        IEnumerable<T> GetAllPaginated<S>(int pageIndex, int pageSize, ISpecification<T> spec, Expression<Func<T, S>> orderByExpression, bool ascending, string include, out int totalRows);

        IEnumerable<T> GetAllSorted(string orderColumn, bool ascending);
        IEnumerable<T> GetAllSorted<S>(Expression<Func<T, S>> orderByExpression, bool ascending);

        IEnumerable<T> GetFiltered(Expression<Func<T, bool>> filter);

        T GetByID(int id);

        void Add(T entity);
        void Delete(T entity);
        void Delete(IList<T> entity);
        bool Modify(T entity);
        bool Duplicate(T entity);
    }
}
